

use "data_for_fee.dta",clear



********************************************************
***Table 3***
********************************************************

*** without controls (d7_fee) ***
sum f_d7_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d7_fee  frate_stock log_turnover log_marketcap DIVY flag_high log_per log_vola ///
							etf_cum5 etf_cum5_flag_high ///
					if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_cum5>0  & etf_cum5<.   ///
					& f_d7_fee <`r(p99)' & f_d7_fee>`r(p1)' , ///
a(QUICK DataDate) vce(cluster QUICK DataDate)


*** without controls (d2w_fee) ***
sum f_d2w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d2w_fee  frate_stock log_turnover log_marketcap DIVY flag_high log_per  log_vola ///
							etf_2w etf_2w_flag_high ///
					if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_2w>0  & etf_2w<.   ///
					& f_d2w_fee <`r(p99)' & f_d2w_fee>`r(p1)' , ///
a(QUICK DataDate) vce(cluster QUICK DataDate)


*** without controls (d5w_fee) ***
sum f_d5w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d5w_fee  frate_stock log_turnover log_marketcap DIVY flag_high log_per  log_vola ///
							etf_5w etf_5w_flag_high ///
					if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_5w>0  & etf_5w<.   ///
					& f_d5w_fee <`r(p99)' & f_d5w_fee>`r(p1)' , ///
a(QUICK DataDate) vce(cluster QUICK DataDate)


*** without controls (d15w_fee) ***
sum f_d15w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d15w_fee  frate_stock log_turnover log_marketcap DIVY flag_high log_per  log_vola ///
							etf_15w etf_15w_flag_high ///
					if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_15w>0  & etf_15w<.   ///
					& f_d15w_fee <`r(p99)' & f_d15w_fee>`r(p1)', ///
a(QUICK DataDate) vce(cluster QUICK DataDate)


*** without controls (d25w_fee) ***
sum f_d25w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d25w_fee  frate_stock log_turnover log_marketcap DIVY flag_high log_per  log_vola ///
							etf_25w etf_25w_flag_high ///
					if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_25w>0  & etf_25w<.   ///
					& f_d25w_fee <`r(p99)' & f_d25w_fee>`r(p1)', ///
a(QUICK DataDate) vce(cluster QUICK DataDate)


*** without controls (d50w_fee) ***
sum f_d50w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d50w_fee  frate_stock log_turnover log_marketcap DIVY flag_high log_per  log_vola ///
							etf_50w etf_50w_flag_high ///
							if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_50w>0  & etf_50w<.   ///
					& f_d50w_fee <`r(p99)' & f_d50w_fee>`r(p1)' , ///
a(QUICK DataDate) vce(cluster QUICK DataDate)


*** without controls (d75w_fee) ***
sum f_d75w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d75w_fee  frate_stock log_turnover log_marketcap DIVY flag_high log_per  log_vola ///
							etf_75w etf_75w_flag_high ///
					if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_75w>0  & etf_75w<.   ///
					& f_d75w_fee <`r(p99)' & f_d75w_fee>`r(p1)' , ///
a(QUICK DataDate) vce(cluster QUICK DataDate)


********************
***** Table 4*******
********************


eststo clear

foreach x in 1 2 5 15 25 50 75 {
replace single= etf_`x'w 

*** with controls (d7_fee) ***
sum f_d`x'w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d`x'w_fee  frate_stock log_turnover log_marketcap DIVY flag_high log_per log_vola ///
							  single c.etf_`x'w#1.flag_high  ///
							c.etf_`x'w#c.frate_stock c.etf_`x'w#c.log_turnover ///
							c.etf_`x'w#c.log_marketcap c.etf_`x'w#c.log_per ///
							c.etf_`x'w#c.DIVY c.etf_`x'w#c.log_vola ///
					if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_`x'w>0  & etf_`x'w<.   ///
					& f_d`x'w_fee <`r(p99)' & f_d`x'w_fee>`r(p1)' , ///
a(QUICK DataDate) vce(cluster QUICK DataDate)

}



********************
***** Table A2 *******
********************


foreach x in 1 2 5 15 25 50 75 {
replace single= etf_`x'w 

*** with controls (d7_fee) ***
sum f_d`x'w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d`x'w_fee  frate_stock log_turnover log_marketcap DIVY flag_high75 log_per log_vola ///
							  single c.etf_`x'w#1.flag_high75  ///
							if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_`x'w>0  & etf_`x'w<.   ///
					& f_d`x'w_fee <`r(p99)' & f_d`x'w_fee>`r(p1)' , ///
a(QUICK DataDate) vce(cluster QUICK DataDate)

}



********************
***** Table A2 *******
********************

foreach x in 1 2 5 15 25 50 75 {
replace single= etf_`x'w 

*** with controls (d7_fee) ***
sum f_d`x'w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d`x'w_fee  frate_stock log_turnover log_marketcap DIVY flag_high75 log_per log_vola  ///
							  single c.etf_`x'w#1.flag_high75  ///
							  c.etf_`x'w#c.frate_stock c.etf_`x'w#c.log_turnover ///
							c.etf_`x'w#c.log_marketcap c.etf_`x'w#c.log_per ///
							c.etf_`x'w#c.DIVY c.etf_`x'w#c.log_vola  ///
							if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_`x'w>0  & etf_`x'w<.   ///
					& f_d`x'w_fee <`r(p99)' & f_d`x'w_fee>`r(p1)' , ///
a(QUICK DataDate) vce(cluster QUICK DataDate)

}



********************
***** Table A3 *******
********************

gen fy = year
replace fy = year - 1 if month <= 3
recast long fy

drop _merge
merge m:1 fy QUICK using "Shareholder_type_data_for_StockLending_wide_r.dta"


*** without controls (d7_fee) ***
sum f_d7_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d7_fee frate_stock log_turnover log_marketcap DIVY flag_high log_per log_vola ///
							etf_cum5 etf_cum5_flag_high  Share_PensionTrusts c.Share_PensionTrusts#1.flag_high c.etf_cum5#c.Share_PensionTrusts c.etf_cum5#c.Share_PensionTrusts#1.flag_high ///
					if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_cum5>0  & etf_cum5<.   ///
					& f_d7_fee <`r(p99)' & f_d7_fee>`r(p1)' , ///
a(QUICK DataDate) vce(cluster QUICK DataDate)


*** without controls (d2w_fee) ***
sum f_d2w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d2w_fee frate_stock log_turnover log_marketcap DIVY flag_high log_per log_vola ///
							etf_2w etf_2w_flag_high  Share_PensionTrusts c.Share_PensionTrusts#1.flag_high c.etf_2w#c.Share_PensionTrusts c.etf_2w#c.Share_PensionTrusts#1.flag_high ///
					if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_2w>0  & etf_2w<.   ///
					& f_d2w_fee <`r(p99)' & f_d2w_fee>`r(p1)', ///
a(QUICK DataDate) vce(cluster QUICK DataDate)


*** without controls (d5w_fee) ***
sum f_d5w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d5w_fee  frate_stock log_turnover log_marketcap DIVY flag_high log_per log_vola ///
							etf_5w etf_5w_flag_high  Share_PensionTrusts c.Share_PensionTrusts#1.flag_high c.etf_5w#c.Share_PensionTrusts c.etf_5w#c.Share_PensionTrusts#1.flag_high  ///
					if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_5w>0  & etf_5w<.   ///
					& f_d5w_fee <`r(p99)' & f_d5w_fee>`r(p1)' , ///
a(QUICK DataDate) vce(cluster QUICK DataDate)


*** without controls (d15w_fee) ***
sum f_d15w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d15w_fee  frate_stock log_turnover log_marketcap DIVY flag_high log_per log_vola ///
							etf_15w etf_15w_flag_high Share_PensionTrusts c.Share_PensionTrusts#1.flag_high c.etf_15w#c.Share_PensionTrusts c.etf_15w#c.Share_PensionTrusts#1.flag_high  ///
					if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_15w>0  & etf_15w<.   ///
					& f_d15w_fee <`r(p99)' & f_d15w_fee>`r(p1)', ///
a(QUICK DataDate) vce(cluster QUICK DataDate)


*** without controls (d25w_fee) ***
sum f_d25w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d25w_fee  frate_stock log_turnover log_marketcap DIVY flag_high log_per log_vola ///
							etf_25w etf_25w_flag_high  Share_PensionTrusts c.Share_PensionTrusts#1.flag_high c.etf_25w#c.Share_PensionTrusts c.etf_25w#c.Share_PensionTrusts#1.flag_high  ///
					if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_25w>0  & etf_25w<.   ///
					& f_d25w_fee <`r(p99)' & f_d25w_fee>`r(p1)', ///
a(QUICK DataDate) vce(cluster QUICK DataDate)


*** without controls (d50w_fee) ***
sum f_d50w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d50w_fee  frate_stock log_turnover log_marketcap DIVY flag_high log_per log_vola ///
							etf_50w etf_50w_flag_high  Share_PensionTrusts c.Share_PensionTrusts#1.flag_high c.etf_50w#c.Share_PensionTrusts c.etf_50w#c.Share_PensionTrusts#1.flag_high  ///
							if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_50w>0  & etf_50w<.   ///
					& f_d50w_fee <`r(p99)' & f_d50w_fee>`r(p1)' , ///
a(QUICK DataDate) vce(cluster QUICK DataDate)


*** without controls (d75w_fee) ***
sum f_d75w_fee if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020), detail
eststo: reghdfe f_d75w_fee  frate_stock log_turnover log_marketcap DIVY flag_high log_per log_vola ///
							etf_75w etf_75w_flag_high Share_PensionTrusts c.Share_PensionTrusts#1.flag_high c.etf_75w#c.Share_PensionTrusts c.etf_75w#c.Share_PensionTrusts#1.flag_high  ///
					if DataDate>=mdy(12,1,2010) & DataDate<mdy(1,1,2020) & etf_75w>0  & etf_75w<.   ///
					& f_d75w_fee <`r(p99)' & f_d75w_fee>`r(p1)' , ///
a(QUICK DataDate) vce(cluster QUICK DataDate)


